package com.hk.employeemanagementsystem.service.impl;

import com.hk.employeemanagementsystem.entity.PoliticalEntity;
import com.hk.employeemanagementsystem.mapper.PoliticalEntityMapper;
import com.hk.employeemanagementsystem.service.PoliticalEntityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author by 何坤
 * @Classname PoliticalEntityServiceImpl
 * @Description TODO
 * @Date 2020/1/2 23:40
 */
@Service
public class PoliticalEntityServiceImpl implements PoliticalEntityService {

    @Resource
    private PoliticalEntityMapper politicalEntityMapper;

    @Resource
    private RedisTemplate<String, PoliticalEntity> redisTemplate;

    @Cacheable(value = "political", key = "'all'", unless = "#result==null || #result.size()==0")
    @Override
    public List<PoliticalEntity> selectAllPolitical() {
        return politicalEntityMapper.selectList(null);
    }
}
